<cfparam name="URL.bq" default="knit pattern"><!--- Default search term to show working example --->
<cfset Variables.key=""><!--- Your long API key --->
<cfset Variables.PrefixString="Tropical+Yarns+and+Elegant+Stitches"><!--- Your company name or unique phrase in your listings --->
<cfset Variables.MaxResults="10">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Google Base Quick Search</title>
</head>
<body> 
<h3>Google Base Quick Search</h3>

<!--- Search form ---> 
<FORM name="gbsearch" action="index.cfm" method="get"> 
  	<cfoutput><INPUT name="bq" type="text" size="30" value="#URL.bq#"></cfoutput> 
	&nbsp;&nbsp;<input type="submit" value="Search"> 
	&nbsp;&nbsp;<a href="sample_code.txt" target="_blank">Download the sample code</a><br> 
</FORM>

<!--- Output results if search term provided --->
<cfif Len(URL.bq)>
	<!--- Prefix the search query if prefix is provided --->
	<cfif Len(Variables.PrefixString)>
		<cfset Variables.SearchString = Variables.PrefixString & "+" & URL.bq>
	<cfelse>
		<cfset Variables.SearchString = URL.bq>
	</cfif>
	<cftry>
		<!--- Make HTTP call to Google Base with search query terms --->
		<cfhttp method="Get" url="http://www.google.com/base/feeds/snippets/-/products?bq=#Variables.SearchString#&max-results=#Variables.MaxResults#"> 
			<cfhttpparam name="X-Google-Key" type="Header" value="key=#Variables.key#"> 
		</cfhttp>
		<cfset objXML = xmlparse(cfhttp.fileContent)> 
		<cfset XMLVALIDATION = true>
		<!--- <cfdump var="#objXML#"> --->
		<!--- HTTP call or XML parse failed --->
		<cfcatch type="any">
			<cfset XMLVALIDATION = false>
		</cfcatch>
	</cftry>
	<!--- Display output if results passed validation --->
	<cfif XMLVALIDATION> 
		<!--- Remove comments here if you want to see the full response structure <cfdump var="#objxml#">  --->
		<cfif isdefined("objXML.feed.entry")> 
			<cfoutput>
				Most relevant results for "<b>#URL.bq#</b>" from the Base:<br /><br/> 
				<table border="1"> 
					<cfloop index="ntrys" from="1" to="#arraylen(objXML.feed.entry)#"> 
						<cfset tmp_Entry = objXML.feed.entry[ntrys]> 
						<tr>
							<td align="right" style="vertical-align: top;">
								<cfif StructKeyExists(objXML.feed.entry[ntrys], "g:image_link")> 
									<a href="#tmp_Entry.link.xmlattributes.href#"><img src="#tmp_Entry["g:image_link"]["xmltext"]#" border="0" width="200"></a> 
								<cfelse> 
									No image
								</cfif>
							</td>
							<td style="vertical-align: top;">
								<b><a href="#tmp_Entry.link.xmlattributes.href#">#tmp_Entry.title.xmltext#</a></b>: #tmp_Entry.content.xmltext#
							</td>
						</tr>
					</cfloop> 
				</table>
			</cfoutput>
		<cfelse> 
			No search results found.<br/> 
		</cfif>
	<cfelse>
		Failed to get valid results.<br/>
	</cfif>
</cfif> 
Search results powered by <a href="http://base.google.com">Google Base</a>.
</body>
</html>